<?php $this->_extends('_layouts/main_layout'); ?>
<?php $this->_block('title'); ?>
	Update Email Offer
<?php $this->_endblock(); ?>

<?php $this->_block('contents'); ?>

<div id="content" class="box">
	<h1>Email Offers</h1>
		<?php if (isset($infos)) 
				{
					foreach ($infos as $info)
					{
		?>
				<p class="msg info"><?php echo $info;?></p>
		<?php		}
				}
		?>
		<fieldset>
			<legend>Email Offers</legend>
		<?php if (isset($errors)) 
				{
					foreach ($errors as $error)
					{
		?>
				<p class="msg error"><?php echo $error;?></p>
		<?php		}
				}
		?>
			<form method="post" action="<?php echo url('offermanager/update');?>">
				<input type="hidden" name="id" value="<?php echo isset($emailOffer['id']) ? $emailOffer['id'] : '';?>" />
				<dl>
					<dt><label>Name:</label></dt>
					<dd>
						<input class="txt_link" type="text" name="name" id="name" value="<?php echo isset($emailOffer['name']) ? $emailOffer['name'] : '';?>" />
					</dd>
				</dl>
				<dl>
					<dt><label>Subject:</label></dt>
					<dt>Set Email Offers Subject( Write [[firstname]] as a placeholder ):</dt>
					<dd>
						<input class="txt_link" type="text" name="subject" id="subject" value="<?php echo isset($emailOffer['subject']) ? $emailOffer['subject'] : ''; ?>" />
					</dd>
				</dl>
				<dl>
					<dt><label>Offer Name:</label></dt>
					<dd>
						<select name="offer_name">
							<option value="PeanutLabs" <?php echo (isset($emailOffer['offer_name']) && $emailOffer['offer_name'] == 'PeanutLabs') ? 'selected=selected' : '';?>>Peanut Labs</option>
							<option value="SuperRewards" <?php echo (isset($emailOffer['offer_name']) && $emailOffer['offer_name'] == 'SuperRewards') ? 'selected=selected' : '';?>>Super Rewards</option>
							<option value="RadiumOne" <?php echo (isset($emailOffer['offer_name']) && $emailOffer['offer_name'] == 'RadiumOne') ? 'selected=selected' : '';?>>Radium One</option>
							<option value="SponsorPay" <?php echo (isset($emailOffer['offer_name']) && $emailOffer['offer_name'] == 'SponsorPay') ? 'selected=selected' : '';?>>SponsorPay</option>
						</select>
					</dd>
				</dl>
				<dl>
					<dt><label>Offer ID:</label></dt>
					<dd>
						<input type="text" name="offer_id" id="offer_id" value="<?php echo isset($emailOffer['offer_id']) ? $emailOffer['offer_id'] : ''; ?>" />
					</dd>
				</dl>
				<dl>
					<dt><label>Site:</label></dt>
					<dd>
						<?php
							 echo Util::buildDropDownList(
							 	array('id'=>'site', 'name'=>'site_id'),
							 	$sites,
							 	isset($emailOffer['site_id']) ? $emailOffer['site_id']: false,
							 	array('k'=>'', 'l'=>'--All--')
							 );
						?>
					</dd>
				</dl>
				<dl>
					<dt><label>Picture URL:</label></dt>
					<dd><input type="text" name="picture_url" value="<?php echo isset($emailOffer['picture_url']) ? $emailOffer['picture_url'] : '';?>" class="txt_link"/></dd>
					<dt><label>Picture Width:</label></dt>
					<dd><input type="text" name="picture_width" value="<?php echo isset($emailOffer['picture_width']) ? $emailOffer['picture_width'] : '';?>" class="txt_link"/></dd>
					<dt><label>Picture Height:</label></dt>
					<dd><input type="text" name="picture_height" value="<?php echo isset($emailOffer['picture_height']) ? $emailOffer['picture_height'] : '';?>" class="txt_link"/></dd>
				</dl>
				<dl>
					<dt><label>Link URL:</label></dt>
					<dd>
						<input type="text" name="link_url" value="<?php echo isset($emailOffer['link_url']) ? $emailOffer['link_url'] : '';?>" class="txt_link"/>
					</dd>
					<dd>
						<label style="color:#F00;">Paramaters: publisherId=?, oid=?, endUserId( = INSERT_END_USER_ID as a placeholder), email( = INSERT_END_USER_EMAIL as a placeholder)</label>
					</dd>
				</dl>
				<dl>
					<dt><label>Tosent Date</label></dt>
					<dd>
						<input type="text" name="tosent_date" class="myDatePickerClass" readonly="readonly" />
						<script type="text/javascript">
	                       	$(".myDatePickerClass").datepicker({
	                           	dateFormat:'yy-mm-dd',
	                           	changeYear: true,
	                           	changeMonth: true,
	                        	showMonthAfterYear: true,
	                    	}).val('<?php echo isset($emailOffer['tosent_date'])? $emailOffer['tosent_date'] : date('Y-m-d'); ?>');
	                	</script>
					</dd>
				</dl>
				<dl>
					<dt><label>Order:</label></dt>
					<dd>
						<select name="order">
							<option value="1" <?php echo (isset($emailOffer['ord']) && $emailOffer['ord'] == 1) ? 'selected=selected' : '';?>>1</option>
							<option value="2" <?php echo (isset($emailOffer['ord']) && $emailOffer['ord'] == 2) ? 'selected=selected' : '';?>>2</option>
							<option value="3" <?php echo (isset($emailOffer['ord']) && $emailOffer['ord'] == 3) ? 'selected=selected' : '';?>>3</option>
							<option value="4" <?php echo (isset($emailOffer['ord']) && $emailOffer['ord'] == 4) ? 'selected=selected' : '';?>>4</option>
							<option value="5" <?php echo (isset($emailOffer['ord']) && $emailOffer['ord'] == 5) ? 'selected=selected' : '';?>>5</option>
						</select>
					</dd>
				</dl>
				<dl>
					<dt><label>Gender:</label></dt>
					<dd>
						<select name="gender">
							<option value="" <?php echo (isset($emailOffer['gender']) && $emailOffer['gender'] == "") ? 'selected=selected' : '';?>>ALL</option>
							<option value="M" <?php echo (isset($emailOffer['gender']) && $emailOffer['gender'] == "M") ? 'selected=selected' : '';?>>Male</option>
							<option value="F" <?php echo (isset($emailOffer['gender']) && $emailOffer['gender'] == "F") ? 'selected=selected' : '';?>>Female</option>
						</select>
					</dd>
				</dl>
				<input type="submit" value="Update Email Offer" /> 
			</form>
		</fieldset>
		
</div>
<?php $this->_endblock(); ?>